package com.twu.biblioteca;

import java.io.BufferedReader;


public class CheckOutState implements State {

    private Library library;
    protected int bookIndex;

    public CheckOutState(Library library, int bookIndex) {
        this.bookIndex = bookIndex;
        this.library = library;
    }

    @Override
    public State next(BufferedReader reader) {
        return new MenuState(library);  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getMessage() {
        String message = "";
        if (library.listBooks().get(bookIndex).getAvailability()) {
            message = "Thank You! Enjoy the book.\n\n";
            library.bookList.get(bookIndex).setAvailability(false);
        }
        else {
            message = "Sorry we don't have that book yet.\n\n";
        }
        return message;
    }
}
